package com.shareppy.normanapitest.entity;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import com.shareppy.norman.core.entity.AbstractEntity;
import com.shareppy.normanapitest.lexic.LexicalAnalyzer;
import com.shareppy.utils.ReflectionUtils;

public class QueryProcessor {

	private static Map<String, String> entities = new HashMap<String, String>();

	public static void main(String... args) throws IOException {
		BufferedReader reader = new BufferedReader(new FileReader(new File(
				"queries", "user.json")));
		loadEntities();
		String line = "";
		StringBuilder program = new StringBuilder();
		while ((line = reader.readLine()) != null) {
			program.append(line);
		}
		reader.close();
		
		LexicalAnalyzer lexicalAnalyzer = new LexicalAnalyzer();
		lexicalAnalyzer.analize(program.toString());
	}

	private static void loadEntities() {
		try {
			Class<?>[] classes = ReflectionUtils
					.getClasses(QueryProcessor.class.getPackage().getName());
			for (Class<?> clazz : classes) {
				if (AbstractEntity.class.isAssignableFrom(clazz)) {
					entities.put( clazz.getName() , "1");
				}
			}
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}